import com.sun.corba.se.impl.logging.POASystemException;

public class TestPaper implements Paper {
    private int charPerLine = 16;
    public int linePerPage = 5;
    private String content = "";
    private int posX = 0;
    private int posY = 0;
    private int posP = 1;


    @Override
    public void putInChar(char c) {
        content +=c;
        ++posX;
        if (posX == charPerLine) {
            content += Paper.newline;
            posX = 0;
            ++posY;
        }
        if (posY == linePerPage) {
            content += "==第" + posP + "页==";
            content+=Paper.newline+Paper.newline;
            ++posP;
        }

    }

    @Override
    public String getContent() {
        String ret = this.content;
        if (!(posX == 0 && posY == 0)) {
            int count = linePerPage-posY;
            for (int i = 0; i < count; ++i) {
                ret+=Paper.newline;
            }
            ret += "==第" + posP + "页==";
        }
        return ret;


    }

    public int getLinePerPage() {
        return linePerPage;
    }

    public void setLinePerPage(int linePerPage) {
        this.linePerPage = linePerPage;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getPosX() {
        return posX;
    }

    public void setPosX(int posX) {
        this.posX = posX;
    }

    public int getPosY() {
        return posY;
    }

    public void setPosY(int posY) {
        this.posY = posY;
    }

    public int getPosP() {
        return posP;
    }

    public void setPosP(int posP) {
        this.posP = posP;
    }

    public int getCharPerLine() {
        return charPerLine;
    }

    public void setCharPerLine(int charPerLine) {
        this.charPerLine = charPerLine;
    }


}
